package com.night.attendance.excelHandler;

import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.write.handler.CellWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import org.apache.poi.ss.usermodel.Cell;

import java.util.List;

/**
 * @author Dark-Morning
 * 2022/10/21 9:10
 */
public class AttendanceRecordHandler implements CellWriteHandler {
    private int count = 0;
    @Override
    public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
        if (isHead && cell.getColumnIndex() == 0) {
            cell.setCellValue("序号");
        }
        if (!isHead && cell.getColumnIndex() == 4) {
            if ("0".equals(cell.getStringCellValue())){
                cell.setCellValue("未签到");
            } else{
                cell.setCellValue("已签到");
            }
        }
        if (!isHead && cell.getColumnIndex() == 0) {
                cell.setCellValue(++count);
        }
    }
}
